
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%><%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> 
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%> 
<%@ include file="/include/head.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="<%=request.getContextPath()%>/resources/servicePro/jquery.uploadify.min.js"></script>
<link rel="stylesheet" href="<%=request.getContextPath()%>/resources/servicePro/uploadify.css">
<script type="text/javascript">
      /**删除资讯**/
      function del(id){
      if(confirm("确定要进行此操作吗？"))
        {
           $.ajax( {
					type : "POST",
					url : "<%=request.getContextPath()%>/back/news/delNews.do",
					data:{"id":id},
					dataType: "json",
					async : false,
					success : function(data) {
						if(data.code=="0000"){
				       		 alert("操作成功!");
				       		 location.reload();
				       }else{
				           alert(data.code+data.codeMsg);
				       }
					}
			  });  
        }
        else 
        {
           return false;
        }
	          
      }
      /**跳转到添加资讯页面**/
       function addNews(){
        window.location.href='<%=request.getContextPath()%>/back/news/toAddNew.do';
	          
      }
      /**跳转到修改页面***/
      function gotoupdate(id){
         window.location.href='<%=request.getContextPath()%>/back/news/getNewsDetail.do?newsid='+id;
      }
   </script>
<title>Document</title>


</head>
<body  >
	<div class="container">
		<div class="main_top">

			<div class="main_right fr span10">

				<div class="box pl5">
					<div class="box_border">
						<div class="box_top">
							<div class="box_top_l fl">
								<b class="pl15">数据</b>
							</div>
						</div>
						<div class="box_center">
								<div class="searchDiv fr">
								<input type="button"  id="add_manager"  class="new_btn new_btn_publish new_btn_big" 
											value="添加数据" onclick="addNews()">
								</div>
							<div id="table" class=" fl mt10">
								<div class="box span10 oh">
									<table width="100%" border="0" cellpadding="0" cellspacing="0"
										class="list_table">
										<tr>
											<th width="1.5%">序号</th>
											<th width="3%">资讯名称</th>
											<th width="5%">作者</th>
											<th width="5%">浏览量</th>
											<th width="5%">发布时间</th>
											<th width="5%">操作</th>
										</tr>
										<c:if test="${fn:length(newsBeans)==0}"><tr class="tr"><td align="center" colspan="6">暂无数据</td> </tr></c:if>
										<c:if test="${fn:length(newsBeans)>0}">
										<c:forEach items="${newsBeans}" var="dic" varStatus="abc">
											<tr class="tr">
											    <td align="center"><c:out value="${(PageBean.currentpage-1)*PageBean.pagesize+abc.index + 1}" /></td>
												<td align="center">
												   <c:out value="${dic.title}" />
                                                </td>
												<td align="center">
                                                    <c:out value="${dic.author}" />
                                                 </td>
                                                 <td align="center">
                                                    <c:out value="${dic.pageview}" />
                                                 </td>
                                                 <td align="center">
                                                    <c:out value="${dic.createtime}" />
                                                 </td>
												<td align="center">
												  <input type="button" class="new_btn new_btn_up" value="更新" onclick="gotoupdate('${dic.id}')" >
													<c:if test="${dic.up > 1000}">
														<input type="button" class="new_btn new_btn_up" value="取消置顶" onclick="cancalUpNews('${dic.id}')" >
													</c:if>
													<c:if test="${dic.up ==1000}">
														<input type="button" class="new_btn new_btn_up" value="置顶" onclick="upNews('${dic.id}')" >
													</c:if>
												   <input type="button" class="new_btn new_btn_delete" value="删除"  onclick="javascript:del('${dic.id}');" >
												  </td>
											</tr>
										</c:forEach>
                                     </c:if>
									</table>
									<div class="fr fontblack mt25 mb20 mr20">
										每页条数：<a href="<%=request.getContextPath()%>/back/news/getNewsBeans.do?pz=5"
											class="${pageSize == 5 ? 'fontpink' : ''}">5</a> | <a
											href="<%=request.getContextPath()%>/back/news/getNewsBeans.do?pz=10"
											class="${pageSize == 10 ? 'fontpink' : ''}">10</a> | <a
											href="<%=request.getContextPath()%>/back/news/getNewsBeans.do?pz=20"
											class="${pageSize == 20 ? 'fontpink' : ''}">20</a>
									</div>
									<div class="fr fontblack mt5 mb20 mr20">
										<jsp:include page="../template/commonPagination.jsp">
											<jsp:param name="url" value="getNewsBeans.do?"></jsp:param>
										</jsp:include>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>

			<div class="clear"></div>
		</div>

	</div>
<script type="application/javascript">
	/**
	 * 置顶
	 * @param id
     */
	function upNews(id) {
		$.ajax( {
			type : "POST",
			url : "<%=request.getContextPath()%>/back/news/topNews.do",
			data:{"id":id},
			dataType: "json",
			async : false,
			success : function(data) {
				if(data.code=="0000"){
					alert("操作成功!");
					location.reload();
				}else{
					alert(data.code+data.codeMsg);
				}
			}
		});
	}
	/**
	 * 取消置顶
	 * @param id
	 */
	function cancalUpNews(id) {
		$.ajax( {
			type : "POST",
			url : "<%=request.getContextPath()%>/back/news/cancalTopNews.do",
			data:{"id":id},
			dataType: "json",
			async : false,
			success : function(data) {
				if(data.code=="0000"){
					alert("操作成功!");
					location.reload();
				}else{
					alert(data.code+data.codeMsg);
				}
			}
		});
	}
</script>
</body>

</html>
